{template "mheader.html"}

<div class="portlet light ">
    <div class="portlet-title tabbable-line">
        <ul class="nav nav-tabs" style="float:left;">
            {loop $module_memu $i $t}
            <li class="{if $mcid==$i}active{/if}">
                <a href="{$t.url}"> <i class="{$t.icon}"></i> {$t.name} </a>
            </li>
            {/loop}
            {if $id}
            <li class="active">
                <a href="{dr_now_url()}"> <i class="fa fa-edit"></i> 修改 </a>
            </li>
            {/if}
        </ul>
    </div>
    <div class="portlet-body">

        <form action="" class="form-horizontal" method="post" name="myform" id="myform">
            {$form}
            <div class="row myfbody">
                <div class="col-md-12">

                    <div class="portlet light bordered">
                        <div class="portlet-title">
                            <div class="caption">
                                <span class="caption-subject font-green sbold ">{dr_lang('基本内容')}</span>
                            </div>

                            <div class="actions">
                                {if $draft_list && !$is_verify}
                                <div class="btn-group">
                                    <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="javascript:;" aria-expanded="false">
                                        {dr_lang('草稿')}
                                        <i class="fa fa-angle-down"></i>
                                    </a>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a href="{$draft_url}"> {dr_lang('查看原文')} </a>
                                        </li>
                                        {loop $draft_list $t}
                                        <li>
                                            <a href="{$draft_url}&did={$t.id}" {if $t.id==$did}style="color:red"{/if}> {dr_date($t.inputtime)} </a>
                                        </li>
                                        {/loop}
                                    </ul>
                                </div>
                                {/if}
                                <div class="btn-group">
                                    <a class="btn" href="{$reply_url}"> <i class="fa fa-mail-reply"></i> {dr_lang('返回列表')}</a>
                                </div>
                            </div>
                        </div>
                        <div class="portlet-body">
                            <div class="form-body">
                                <div class="form-group">
                                    <label class="col-md-2 control-label">{dr_lang('栏目')}</label>
                                    <div class="col-md-9">

                                        {if $module['category'][$catid]['setting']['notedit']}
                                        <label style="margin-top: 7px;">
                                            <span class="label label-sm label-success circle">{$module['category'][$catid]['name']}</span>
                                        </label>
                                        <input type="hidden" id="dr_catid" name="catid" value="{$catid}">
                                        {else}
                                        <label>{$select}</label>
                                        {if $module['setting']['sync_category']}
                                        {if !$id || $is_sync_cat}
                                        <label style="margin-right:10px"><a href="javascript:;" onclick="dr_syncat()">[{dr_lang('同步发布到其他栏目')}]</a></label>
                                        <label>
                                            <input id="dr_syncatid" name="sync_cat" type="hidden" value="{$is_sync_cat}" />
                                            <span id="dr_syncat_text" class="label label-success" style="display: {if $is_sync_cat}blank{else}none{/if};"><b id="dr_syncat_num">{php echo substr_count($is_sync_cat, ',') + 1;}</b></span>
                                        </label>
                                        {else if $link_id != 0}
                                        <label>{dr_lang('修改内容时会同步更新其他外联文档')}</label>
                                        {/if}
                                        {/if}
                                        {/if}
                                    </div>

                                </div>
                                {$myfield}
                                {if $is_post_code}
                                <div class="form-group" id="dr_row_code">
                                    <label class="control-label col-md-2"><span class="required" aria-required="true"> * </span> {dr_lang('验证码')}</label>
                                    <div class="col-md-5">
                                        <label>
                                            <div class="form-recaptcha" style="width:270px;">
                                                <div class="input-group">
                                                    <input type="text" id="dr_code" class="form-control" name="code">
                                                    <div class="input-group-btn fc-code">
                                                        {dr_code(120, 35)}
                                                    </div>
                                                </div>
                                            </div>
                                        </label>
                                    </div>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>

                    {if $diyfield}
                    <div class="portlet  ">
                        <div class="portlet-body">
                            <div class="form-body">
                                {$diyfield}
                            </div>
                        </div>
                    </div>
                    {/if}

                    {if $is_verify}
                    <div class="portlet  ">
                        <div class="portlet-body">
                            <div class="form-body">
                                <div class="form-group">
                                    <label class="col-md-2 control-label">审核人</label>
                                    <div class="col-md-9">
                                        <p class="form-control-static">
                                            {$backinfo.author}
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label">审核时间</label>
                                    <div class="col-md-9">
                                        <p class="form-control-static">
                                            {dr_date($backinfo.optiontime)}
                                        </p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-2 control-label">拒绝理由</label>
                                    <div class="col-md-9">
                                        <p class="form-control-static">
                                            {$backinfo.backcontent}
                                        </p>
                                    </div>
                                </div>


                            </div>
                        </div>
                    </div>
                    {/if}

                </div>
            </div>

            <div class="portlet-body form myfooter">
                <div class="form-actions text-center">
                    {if $is_verify}
                    <button type="button" onclick="$('#dr_is_draft').val(0);dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('提交重新审核')}</button>
                    {else}
                    <label><button type="button" onclick="$('#dr_is_draft').val(0);dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存内容')}</button></label>
                    <label><button type="button" onclick="$('#dr_is_draft').val(0);dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$post_url}&catid='+$('#dr_catid').val())" class="btn blue"> <i class="fa fa-plus"></i> {dr_lang('保存再添加')}</button></label>
                    <label><button type="button" onclick="$('#dr_is_draft').val(0);dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}')" class="btn yellow"> <i class="fa fa-mail-reply-all"></i> {dr_lang('保存并返回')}</button></label>
                    <label><button type="button" onclick="$('#dr_is_draft').val(1);dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn red"> <i class="fa fa-pencil"></i> {dr_lang('保存草稿')}</button></label>
                    {/if}
                </div>
            </div>
        </form>

    </div>
</div>


<script>
    function show_category_field(catid) {
        {if $category_field_url}
        window.location.href = '{$category_field_url}&catid='+catid;
        {/if}
        }
        function dr_syncat() {
            var width = '40%';
            var height = '60%';
            var title = '<i class="fa fa-refresh"></i> {dr_lang('同步到其他栏目')}';
            var url = '{dr_member_url(MOD_DIR.'/home/syncat_edit')}&catid='+$('#dr_syncatid').val();
            layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                shade: 0,
                area: [width, height],
                btn: [lang['ok']],
                yes: function(index, layero){
                    var body = layer.getChildFrame('body', index);
                    $(body).find('.form-group').removeClass('has-error');
                    // 延迟加载
                    var loading = layer.load(2, {
                        shade: [0.3,'#fff'], //0.1透明度的白色背景
                        time: 10000
                    });
                    $.ajax({type: "POST",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
                        success: function(json) {
                            layer.close(loading);
                            if (json.code == 1) {
                                layer.close(index);
                                $('#dr_syncatid').val(json.data);
                                $('#dr_syncat_text').show();
                                $('#dr_syncat_num').html(json.msg);
                            } else {
                                dr_tips(json.code, json.msg);
                            }
                            return false;
                        },
                        error: function(HttpRequest, ajaxOptions, thrownError) {
                            dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError);
                        }
                    });
                    return false;
                },
                content: url+'&is_ajax=1'
            });
        }
</script>
{template "mfooter.html"}